package io.gitee.kotle.android.utils

import java.lang.reflect.ParameterizedType

/**
 * 将class转为ParameterizedType，方便获取此类的类泛型
 */
fun Class<*>?.getParameterizedType(): ParameterizedType? {
    if (this == null) {
        return null
    }
    val type = this.genericSuperclass
    return if (type == null || type !is ParameterizedType) {
        this.superclass.getParameterizedType()
    } else {
        type
    }
}